Repository navigation
tasklist: start every unblocked task when a task finishes - #1663
Open
NathanGray-ChurchillNavigation wants to merge 2 commits into
Open
NathanGray-ChurchillNavigation wants to merge 2 commits into
NathanGray-ChurchillNavigation wants to merge 2 commits into
Conversation
The consumer used to queue only the first IDLE task whose resources had become free, so any other task unblocked by the same completion stayed IDLE until some later task finished. Collect every runnable task under the lock and queue them all after unlocking. Fixes aptly-dev#1662
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1663 +/- ##
==========================================
- Coverage 77.91% 77.64% -0.28%
==========================================
Files 165 165
Lines 16141 16141
==========================================
- Hits 12577 12532 -45
- Misses 2350 2400 +50
+ Partials 1214 1209 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A task picked by one completion stays IDLE until the consumer receives it, so another completion could pick it again. Resources marked in use prevent that for most tasks, but a task with no resources marks nothing, and could run twice and drive the WaitGroups negative. Track that a task was handed to the consumer and skip it when rescanning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1662
Description of the Change
When a task finishes, the consumer now queues every IDLE task whose resources are free, instead of stopping at the first one. Each pick is still marked in use under the list lock before the scan moves on, so a later task that conflicts with an earlier pick stays blocked, and the channel sends still happen after unlocking (as #1529 set up).
A picked task stays IDLE until the consumer receives it, so tasks now carry an unexported
queuedflag, set under the lock wherever they are queued, and the rescan skips them. Without it, a task with no resources (which marks nothing in use) could be picked by two completions and run twice. Master has a narrower version of the same race, betweenRunTaskInBackgroundand a completion, which this also closes.One completion can now start several tasks at once. Tasks with disjoint resources could already run in parallel when submitted directly, so this doesn't add a new kind of concurrency.
Tests:
TestAllUnblockedTasksStartfails on master: C stays IDLE while B runs. It also checks that a waiter that conflicts with B stays blocked.TestReleasedTasksRunOncereleases 50 resource-free tasks at once and checks each runs exactly once. Without thequeuedflag it panics with a negative WaitGroup counter.Both pass repeatedly with and without
-race.Checklist
AUTHORS